<template>
  <div>
    <div class="swiper_box">
      <div class="head">
        <p style="margin-left: 20px"><slot name="title"></slot></p>
      </div>
      <div class="swi">
        <el-carousel
          :interval="5000"
          arrow="always"
          height="340px"
          indicator-position="outside"
        >
          <el-carousel-item v-for="item in 4" :key="item">
            <div class="swi_main">
              <ul style="padding: 0 50px">
                <li
                  v-for="items in guessList.slice(item, item + 4)"
                  :key="items.id"
                >
                  <img
                    :src="items.picture"
                    alt=""
                    style="width: 200px; height: 200px; margin-top: 20px"
                  />
                  <p class="text" style="line-height: 60px; font-size: 16px">
                    {{ items.name }}
                  </p>
                  <p class="price" style="color: #d12424">
                    ￥{{ items.price }}
                  </p>
                  <!-- <p style="height: 50px;">1</p> -->
                </li>
              </ul>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>

<script>
import { getGuessLike } from "../apis/cart";
export default {
  data() {
    return {
      // title:'',
      guessList: [],
    };
  },
  methods: {
    // 猜你喜欢
    async getGuess() {
      let res = await getGuessLike();
      console.log(res);
      this.guessList = res.result.items;
      console.log(this.guessList);
    },
  },
  created() {
    this.getGuess();
  },
};
</script>

<style lang="scss" scoped>
.swiper_box {
  background: white;
  margin-top: 20px;
  .head {
    p {
      line-height: 80px;
      font-size: 24px;
    }
  }
  .swi {
    .swi_main {
      ul {
        display: flex;
        justify-content: space-evenly;
        li {
          text-align: center;
          .text {
            width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
  }
}
</style>